package com.edu.exam.enums.grading;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 在线状态枚举
 *
 * <p>定义协作批阅中参与者的在线状态，包括在线、离线、忙碌、离开等状态。</p>
 *
 * @author System
 * @version 1.0.0
 * @since 2025-11-13
 */
public enum OnlineStatus implements BaseEnum {

    /** 在线 */
    ONLINE("ONLINE", "在线"),

    /** 离线 */
    OFFLINE("OFFLINE", "离线"),

    /** 忙碌 */
    BUSY("BUSY", "忙碌"),

    /** 离开 */
    AWAY("AWAY", "离开"),

    /** 请勿打扰 */
    DO_NOT_DISTURB("DO_NOT_DISTURB", "请勿打扰");

    private final String code;
    private final String description;

    OnlineStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static OnlineStatus fromCode(String code) {
        for (OnlineStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown online status code: " + code);
    }

    @Override
    public String toString() {
        return description;
    }
}